import UIBaseWindow from "../UIBaseWindow";
import { FairyGUI , UnityEditor , System } from 'csharp';
import PanelRegister from "../PanelRegister";
import EGlist from "../common/EGlist";
import UrlUtils from "../../com/utils/UrlUtils";
import EditableTreeItem from "../items/EditableTreeItem";
/*
 *
 *@author clong 2020.11.01
 */
export default class UIPluginView extends UIBaseWindow {

    private btn_confim:FairyGUI.GButton;

    private eglist_items:EGlist;

    constructor() {

        super("plugin", "UIPluginView");
    }

    initUI():void{

        super.initUI();
    }

    registerClass():void{

        PanelRegister.registerClass( "Basic" , "EditableTreeItem" , EditableTreeItem );
    }

    onBtnClick(btn: any): void {

        super.onBtnClick(btn);

        if( btn == this.btn_confim ){
            
            console.log("----->UnityEditor.EditorUtility: " + UrlUtils.FAIRUI );
            // let url = UnityEditor.EditorUtility.OpenFolderPanel("选择目录","","");

            let files = System.IO.Directory.GetFiles( UrlUtils.FAIRUI );
            let arr:Array<string> = [];
            console.log("----->files.length: " + files.length );
            // for(let i=0;i<files.length;i++){
            //     let str = files[i];
            //     console.log("----->files: " + str );
            //     arr.push( str );
            // }
            
            this.eglist_items.array = files;
        }
    }

}